<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
   <meta name="description" content="">
    <meta name="author" content="ThemeBucket"> 
    <link rel="shortcut icon" href="#" type="image/png">
    <title>登录</title>
    <link href="css/style.css" rel="stylesheet">
    <link href="css/style-responsive.css" rel="stylesheet">
</head>

<body class="login-body">

<div class="container">

    <div class="form-signin">
        <div class="form-signin-heading text-center">
            <h1 style="color: black">管理学院MRBS</h1>
            <h2 style="color: black">管理员端</h2>
            
        </div>
        
        
        <div class="login-wrap">
            
            <input type="text" id="number" class="form-control" placeholder="教职工号" autofocus>
            <input type="password" id="password" class="form-control" placeholder="密码">

            <button onclick="submit()" class="btn btn-lg btn-login btn-block" type="submit">
                <i class="fa fa-check"></i>
            </button>
            <label class="checkbox">
                <input type="checkbox" value="remember-me"> 记住密码
                <span class="pull-right">
                    <a data-toggle="modal" href="#myModal"> 忘记密码?</a>

                </span>
            </label>

            <!-- <div class="registration">
                注册
                <a class="" href="registration.html">
                 
                </a>
            </div> -->

        </div>

        <!-- Modal -->
        <div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal" class="modal fade">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">忘记密码 ?</h4>
                    </div>
                    <div class="modal-body">
                        <p>教职工号</p>
                        <input type="text" id="number1" placeholder="工号" autocomplete="off" class="form-control placeholder-no-fix">

                        <p>邮箱</p>
                        <input type="text" id="email" name="email" placeholder="Email" autocomplete="off" class="form-control placeholder-no-fix">

                    </div>
                    <div class="modal-footer">
                        <button data-dismiss="modal" class="btn btn-default" type="button">取消</button>
                        <button class="btn btn-primary" id="forgetpw" type="button" onclick="submit1()">提交</button>
                    </div>
                   
                    
                </div>
            </div>
        </div>
        <!-- modal -->

    </div>

</div>

<!-- Placed js at the end of the document so the pages load faster -->

<!-- Placed js at the end of the document so the pages load faster -->
<script src="js/script/jquery-1.10.2.min.js"></script>
<script src="js/script/bootstrap.min.js"></script>
<script src="js/script/modernizr.min.js"></script>

<!-- lst -->
<script type="text/javascript" src="js/utilcommon.js"></script>
<script>

    function submit(){
        var url=Config.host+"/back/adminLogin";
        var number = $("#number").val();
        var password = $("#password").val();
        var data = {number:number,password:password};
        var func=function(returndata){
            if (returndata.code == "999999"){
                alert("用户不存在");
            }else if (returndata.code == "888888") {
                alert("密码不正确");
            }else{
                setCookie("token2",returndata.data);
                location.href = "index.html";
            }
        }
        AJAX.get(url,data,func);
    }

    //忘记密码，发送邮箱中带有admin表的密码
    function submit1(){
        var number = $("#number1").val();
        var mailbox = $("#email").val();
        console.log(mailbox);
        var url = Config.host + "/back/forgetpw";
        var data = {
            "number": number,
            "mailbox":mailbox
        }
        var func=function(returndata){
            if (returndata.code == "999999"){
                alert("用户不存在");
            }else if (returndata.code == "888888") {
                alert("邮箱不正确");
            }else{
                alert("已为您发送邮件，请耐心等候")
            }

        }
        AJAX.get(url,data,func);
    }


</script>
</body>
</html>
